package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.NamePageVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.RoleIdPageVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.BaseMemberProcessVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.MemberConfigGroupVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.MemberConfigNameVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.RoleManageVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.request.*;
import com.ssy.lingxi.member.merchant.model.vo.validate.response.MemberProcessQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.response.MemberProcessVO;
import com.ssy.lingxi.member.merchant.service.web.IMemberProcessRuleService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 会员能力 - 会员管理流程规则配置相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-17
 */
@RestController
@RequestMapping("/member/process/rule")
public class MemberProcessRuleController {

    @Resource
    private IMemberProcessRuleService memberProcessRuleService;

    /**
     * 分页查询会员流程规则配置列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberProcessQueryVO>> pageMemberProcessRules(@RequestHeader HttpHeaders headers, @Valid NamePageVO pageVO) {
        return memberProcessRuleService.pageMemberProcessRules(headers, pageVO);
    }

    /**
     * 查询入库流程、变更流程列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/base/list", method = RequestMethod.GET)
    public Wrapper<List<BaseMemberProcessVO>> listBaseMemberProcesses(@RequestHeader HttpHeaders headers) {
        return memberProcessRuleService.listBaseMemberProcesses(headers);
    }

    /**
     * 查询角色列表
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/role/page", method = RequestMethod.GET)
    public Wrapper<PageData<RoleManageVO>> pageRoles(@RequestHeader HttpHeaders headers, @Valid NamePageVO pageVO) {
        return memberProcessRuleService.pageRoles(headers, pageVO);
    }

    /**
     * 查询平台默认注册资料
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/role/config/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberConfigNameVO>> pageRoleConfigDetail(@RequestHeader HttpHeaders headers, @Valid RoleIdPageVO pageVO) {
        return memberProcessRuleService.pageRoleConfigDetail(headers, pageVO);
    }

    /**
     * 选择注册资料
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/config/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberConfigNameVO>> pageConfigDetail(@RequestHeader HttpHeaders headers, @Valid RoleIdPageVO pageVO) {
        return memberProcessRuleService.pageConfigDetail(headers, pageVO);
    }

    /**
     * 预览注册资料
     * @param headers Http头部信息
     * @param previewVO 接口参数
     * @return 预览结果
     */
    @RequestMapping(value = "/config/preview", method = RequestMethod.POST)
    public Wrapper<List<MemberConfigGroupVO>> previewMemberDepositoryDetails(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberProcessPreviewVO previewVO) {
        return memberProcessRuleService.previewMemberDepositoryDetails(headers, previewVO);
    }

    /**
     * 新增流程规则配置
     * @param headers Http头部信息
     * @param addVO 接口参数
     * @return 新增结果
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Wrapper<Void> addMemberProcessRule(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberProcessAddVO addVO) {
        return memberProcessRuleService.addMemberProcessRule(headers, addVO);
    }

    /**
     * 修改流程规则配置
     * @param headers Http头部信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberProcessRule(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberProcessUpdateVO updateVO) {
        return memberProcessRuleService.updateMemberProcessRule(headers, updateVO);
    }

    /**
     * 查询流程规则配置详情
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<MemberProcessVO> getMemberProcessRule(@RequestHeader HttpHeaders headers, @Valid MemberProcessIdVO idVO) {
        return memberProcessRuleService.getMemberProcessRule(headers, idVO);
    }

    /**
     * 分页查询流程规则配置关联的入库资料
     * @param headers Http头部信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/deposit/detail/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberConfigNameVO>> pageMemberProcessDepositDetails(@RequestHeader HttpHeaders headers, @Valid MemberProcessDepositDetailPageVO pageVO) {
        return memberProcessRuleService.pageMemberProcessDepositDetails(headers, pageVO);
    }


    /**
     * 修改流程规则状态
     * @param headers Http头部信息
     * @param statusVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update/status", method = RequestMethod.POST)
    public Wrapper<Void> updateMemberProcessRuleStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberProcessIdAndStatusVO statusVO) {
        return memberProcessRuleService.updateMemberProcessRuleStatus(headers, statusVO);
    }

    /**
     * 删除流程规则
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 删除结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteMemberProcessRule(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberProcessIdVO idVO) {
        return memberProcessRuleService.deleteMemberProcessRule(headers, idVO);
    }
}
